<?php
/*********************************************************************************
* Filename: check_answer.php
* 
* This PHP Script checks the value of the security question answer for the team
* and checks if the provided answer is correct.
*
*
* Author: Caleb Goff
* Date Created: 11/15/2009
**********************************************************************************/

//Include common.php to utilize common functions
include_once 'common.php';
require_once "Mail.php";
//Retrieve variables from HTTP POST
$league_id      = $_REQUEST['leagueId'];
$team_id        = $_REQUEST['teamId'];
$answer		    = $_REQUEST['answer'];

$retVal = 0;

$retVal = $league_id;

// Query the database to check the league password against the one provided
$query = "SELECT ANSWER, TEAM_NAME FROM TEAMS WHERE TEAM_ID = '$team_id' AND LEAGUE_ID = '$league_id'";
$result = do_query($query, $g_db_name, $g_username);
$row = mysql_fetch_assoc($result);

if (!$row)
{
	$retVal = 1;
}

$team_answer = $row['ANSWER'];

$retVal = $team_answer;

// If provided answer is correct
//if ($team_answer != $answer)/
//{
//    $retVal = 2;
//} else {
 //   $retVal = 0;
//}

echo $league_id;

?>

